package com.ruoyi.product.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum ProdTypeEnum {

    NORNAL(1, "普通产品")
//    ,QIWEI(2, "企微产品"),
    ;

    Integer value;
    String name;

    ProdTypeEnum(Integer value, String name){
        this.value = value;
        this.name = name;
    }

    public static String getNameByValue(String value){
        for (ProdTypeEnum item : values()) {
            if (StrUtil.equals(value, String.valueOf(item.getValue()))){
                return item.getName();
            }
        }
        return value+"";
    }

    public static List<Map<String, Object>> getListMap() {
        List<Map<String, Object>> listMap = new ArrayList<>();
        for (ProdTypeEnum item : values()) {
            Map<String, Object> itemMap = new HashMap<>();
            itemMap.put("name", item.getName());
            itemMap.put("value", item.getValue());
            listMap.add(itemMap);
        }
        return listMap;
    }


}